<?php
require_once("../../config.inc.php");
require_once("../_inc/mix.func.php");
require_once("../_inc/mbUser.class.php");
require_once("../_inc/sdao/StructuredDataAccessObject.php");
if (!isset($objSDAO)) $objSDAO = new SDAO($aMetaConPar);

if (isset($_REQUEST['xsn'])) {
	session_start();
	$ax = explode('.',$_REQUEST['xsn']);
	$subSess = $ax[0];
	$pageSeq =(isset($ax[1]))?intval($ax[1]):0;
	define('USEROBJ','polarismb'.$subSess);
	define('XSN',"$subSess.$pageSeq");
	define('SUB_SESSION_NUMBER',$subSess);
	// -- update session for log-out
	list($usec, $sec) = explode(" ", microtime());
	$tsNow = date('Y-m-d H:i:s',$sec).substr($usec,1,7); 
	$sSQL = "UPDATE session SET time_last = TIMESTAMP('$tsNow'), log_out = 'Y' " .
		"WHERE uniqid = '".$_SESSION[USEROBJ]->uniqid."' " ;	
	$objSDAO->query($sSQL,"updSess",array("contOnErr"=>true));
	// --
   logRecord(110,"Log out ".$_SESSION[USEROBJ]->user.' - '.$_SESSION[USEROBJ]->name.' '.$_SESSION[USEROBJ]->surname);
	$_SESSION[USEROBJ] = new mbUser("@@logout@@", '');
	serverRedir("login.php?errMsg=9999");
	exit();
}
serverRedir("login.php");
exit();